// =============================================================
/**
 * \class xCoord
 * \brief This is an export class for Coord in order to support various programming languages.
 * \version 0.1
 *
 * \author Woo-Hyun Kim (woorung@nhncorp.com, woorung@gmail.com)
 * \author http://blog.naver.com/wisereign .
 *
 * \date 2008/11/07
 */
// =============================================================
#include "xCoord.h"

xCoord::xCoord(char *name)
{
	coord = new Coord(name);
	coord->autoclean(false);
}

xCoord::~xCoord()
{
	delete coord;
}

int xCoord::write(char *key, char *value)
{
	keyval.first = key;
	keyval.second = value;

	return coord->write(keyval);
}

char *xCoord::read(char *key)
{
	keyval.first = key;
	keyval.second = "";

	int status = coord->read(keyval);

	if(keyval.second=="") return NULL;
	else return (char *)keyval.second.c_str();
}

char *xCoord::readIfExists(char *key)
{
	keyval.first = key;
	keyval.second = "";

	int status = coord->readIfExists(keyval);

	if(keyval.second=="") return NULL;
	else return (char *)keyval.second.c_str();
}

char *xCoord::take(char *key)
{
	keyval.first = key;
	keyval.second = "";

	int status = coord->take(keyval);

	if(keyval.second=="") return NULL;
	else return (char *)keyval.second.c_str();
}

char *xCoord::takeIfExists(char *key)
{
	keyval.first = key;
	keyval.second = "";

	int status = coord->takeIfExists(keyval);

	if(keyval.second=="") return NULL;
	else return (char *)keyval.second.c_str();
}

void xCoord::autoclean(bool is_clean)
{
	coord->autoclean(is_clean);
}

// get size of all the data in local spaces
long xCoord::size()
{
	return coord->size();
}

bool xCoord::alive()
{
	return coord->alive();
}

/*
int xCoord::clean(char *k)
{
	string key = k;

	coord->clean(key);
}

int xCoord::cleanup()
{
	coord->cleanup();
}
*/
